class Solution:
    def minMoves(self, nums: list, limit: int) -> int:
        sums = [0 for _ in range(limit * 2 + 1)]
        mins = [0 for _ in range(limit * 2 + 1)]
        maxs = [0 for _ in range(limit * 2 + 1)]
        for i in range(len(nums) // 2):
            a = nums[i]
            b = nums[len(nums) - i - 1]
            sums[a + b] += 1
            mins[min(a, b)] += 1
            if max(a, b) + limit + 1 <= limit * 2:
                maxs[max(a, b) + limit + 1] += 1
        for i in range(1, 2 * limit + 1):
            maxs[i] += maxs[i - 1]
            mins[2 * limit - i] += mins[2 * limit - i + 1]
        res = len(nums)
        for target in range(2, 2 * limit + 1):
            move = len(nums) // 2 - sums[target]
            move += mins[target]
            move += maxs[target]
            res = min(res, move)
        return res
